function getDCInfoSelect(fatherId) {
	//Get dc list table.
	var dcSelect = document.getElementById("dcSelect");

	var url = "dcmanager/dcListSelect.do";

	var params = {
		fatherId : fatherId
	}

	//Ajax post.
	$.post(url, params, function(data) {
		dcSelect.innerHTML = data;
	});
}

function managerAutoCompl(dcId) {
	var url = "selectDCManagerAutoComplete.do";

	var params = {
		dcId : dcId
	}

	//Ajax post.
	$.post(url, params, function(data) {

		var jsonObj = eval(data);
		//AutoComplete
			$("#approver").autocomplete(jsonObj, {
				minChars : 0,
				width : 125,
				parse : function(data) {

					var row = [];
					for ( var i = 0; i < data.length; i++) {
						row[i] = {
							data : data[i], //������ʾ��ݸ�ʽ 	
							value : data[i].realName, //ֵ(�ǳ���Ҫ��ֻ����String)
							result : data[i].email
						//��ʾ��								
						};
					}
					return row;
				},
				formatItem : function(row, i, max) {
					return row.realName + "\"" + row.empoyeeNum + "\"";
				},
				formatMath : function(row, i, max) {
					return row.realName + " " + row.empoyeeNum;
				},

				formatResult : function(row) {
					return row.email;
				}
			});
		});
}

function createOrder() {
	var dcSelect = document.getElementById("dcSelect");

	var url = "dcauthorization/createForm.do";

	var params = {
		currentUserId : document.getElementById("currentUserId").value,
		dcId : dcSelect.options[dcSelect.selectedIndex].value,
		reason : document.getElementById("reason").value,
		deadline : document.getElementById("deadline").value,
		approverEmail : document.getElementById("approver").value
	}
	//Ajax post.
	$.post(url, params, function(data) {
		//refresh.
			alert("Create Succeed!");
			self.location = "dcauthorization/createorder.jsp";
		});
}

function selectOrderByDcId(dcId) {
	var orderList = document.getElementById("orderList");
	var orderType = document.getElementById("orderType").value;

	var url = "dcauthorization/selectOrderListByDcId.do";

	var params = {
		dcId : dcId,
		orderType : orderType
	}

	//Ajax post.
	$.post(url, params, function(data) {
		orderList.innerHTML = data;
	});
}

function selectOrderByTime() {

}

function selectOrderByApprover() {
	
	var orderType = document.getElementById("orderType").value;
	var url = "dcauthorization/selectOrderListByDcId.do";

	var params = {
		orderType : orderType
	}

	//Ajax post.
	$.post(url, params, function(data) {
		orderList.innerHTML = data;
	});

}

function selectOrderByUserId() {

}

function passOrder(orderId) {
	var url = "dcauthorization/passOrder.do";

	var params = {
		orderId : orderId
	}
	//Ajax post.
	$.post(url, params, function(data) {
		alert(data);
		self.location="dcauthorization/managerorderlist.jsp";
	});
}

function rejectionOrder(orderId) {
	var url = "dcauthorization/rejectionOrder.do";

	var params = {
		orderId : orderId
	}
	//Ajax post.
	$.post(url, params, function(data) {
		alert(data);
		self.location="dcauthorization/managerorderlist.jsp";
	});
}
function refreshOrder() {
	var dcSelect = document.getElementById("dcSelect");
	selectOrderByDcId(dcSelect.options[dcSelect.selectedIndex].value);
}